/* 
 * File:   SelectTable.h
 * Author: vikrantsingh
 *
 * Created on 3 November, 2013, 12:32 AM
 */

#ifndef SELECTTABLE_H
#define	SELECTTABLE_H

#include "../dependency/GlobalStructures.h"
#include "../dependency/QueryStructures.h"

#include <vector>
#include <string>
#include "../Sysfiles/Schema.h"
#include "../PageLayout/Heap.h"
#include "TableScan.h"
#include "../Utils/Timer.h"
#include "../PageLayout/Tuple.h"
#include "../dependency/ExternDefOfGlobalVariables.h"
using namespace std;
class SelectTable {
public:
    SelectTable();
    SelectTable(const SelectTable& orig);
    STATUS_CODE run(QueryStructures *queryStruct);
    virtual ~SelectTable();   
    int loadNextPage();  
    STATUS_CODE fetchResultSet(QueryStructures *queryStruct);
    STATUS_CODE fetchResultSetAll_WithoutIndex(QueryStructures *queryStruct);
    int displayResultSet(QueryStructures *queryStruct) ;
    vector<string> resultSetColumnList_;
    vector<WhereClause> whereConditionExprList_;
    vector<Tuple> resultSet;
//    vector<char *> resultSet_str;
//     char *resultSet_str[250];
//    vector<unsigned> resultSet_str_rec_len;
//     unsigned resultSet_str_rec_len[250];
    bool _allColumns;
    Schema _schema;
    Heap *_heapFile;
    time_t _start, _end;
    double _diff;
    int _totalNumOfRecords;
    int _recordDisplayed;
    Timer _timer;
    vector<RIDStruct> _ridList;
    bool resultFromIndex;
    
    int _currentRidIndexSearch;
    vector<string> _keyList;
    RIDStruct _prePagelastRID; // for paging

private:
    TableScan *_tableScan;
    bool _isTableScanOpen;


};

#endif	/* SELECTTABLE_H */

